home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 25
/
Cream of the Crop 25.iso
/
bbs
/
mhis020.zip
/
DATE.MH
< prev
next >
Wrap
Text File
|
1996-09-16
|
2KB
|
80 lines
#ifndef __DATE_MH
#define __DATE_MH
string date_string (struct _date: d) {
return (itostr ((d.year + 80) % 100) + "\\" + strpadleft (itostr (d.month),2,'0') + "\\"
+ strpadleft (itostr (d.day),2,'0'));
}
void string_to_date (Ref struct _date: d, string: str) {
int: idx, idx2;
long: current_date;
struct _stamp: cur_date_stamp;
idx := stridx (str, 1, '\\');
idx2 := stridx (str, idx + 1, '\\');
if (idx2) {
d.year := strtoi (substr (str, 1, idx - 1)) - 80;
d.month := strtoi (substr (str, idx + 1, idx2 - idx));
d.day := strtoi (substr (str, idx2 + 1, strlen (str) - idx2));
}
else {
current_date := time ();
long_to_stamp (current_date, cur_date_stamp);
d.year := cur_date_stamp.date.year;
d.month := strtoi (substr (str, 1, idx - 1));
d.day := strtoi (substr (str, idx + 1, strlen (str) - idx));
};
}
// returns true if d1 > d2
int date_greater (struct _date: d1, struct _date: d2) {
if (d1.year > d2.year) return True;
if (d1.year = d2.year) {
if (d1.month > d2.month) return True;
if (d1.month = d2.month) {
if (d1.day > d2.day) return True;
};
};
return False;
}
string time_to_string (struct _time: tme) {
string: result;
string: temp;
result := itostr (tme.hh);
if (strlen (result) < 2) result := "0" + result;
if (tme.mm < 10) {
temp := "0" + itostr (tme.mm);
}
else temp := itostr (tme.mm);
result := result + ":" + temp;
return result;
}
string seconds_to_string (unsigned long: seconds) {
int: hours, days, minutes;
string: tempstr, result;
hours := seconds / 3600;
days := hours / 24;
hours := hours % 24;
seconds := seconds % 3600;
minutes := seconds / 60;
if (days > 0) {
result := itostr (days) + " day";
if (days > 1)
result := result + "s";
result := result + ", " + itostr (hours)
+ ":" + strpadleft (itostr (minutes), 2, '0');
}
else {
result := strpadleft (itostr (hours),2,'0') + ":" + strpadleft (itostr (minutes), 2, '0');
};
return result;
}
#endif